"use strict";
cc._RF.push(module, '3c3d7ORxiRFY7Gm4QNnVnTH', 'ItemUI');
// scripts/ItemUI.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _n12,
    i = void 0 && (void 0).__extends || (_n12 = function n(t, e) {
  return (_n12 = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _n12(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    s = void 0 && (void 0).__decorate || function (t, e, o, n) {
  var i,
      s = arguments.length,
      r = s < 3 ? e : null === n ? n = Object.getOwnPropertyDescriptor(e, o) : n;
  if ("object" == (typeof Reflect === "undefined" ? "undefined" : typeof Reflect) && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, n);else for (var c = t.length - 1; c >= 0; c--) {
    (i = t[c]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, o, r) : i(e, o)) || r);
  }
  return s > 3 && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var r = cc._decorator,
    c = r.ccclass,
    a = r.property,
    u = t("Global"),
    l = t("BaseUI"),
    d = t("UIEnum"),
    p = t("UIManager"),
    h = t("SDK"),
    f = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e.childNode = null, e.shareBtn = null, e.videoBtn = null, e.closeBtn = null, e.xipaiNode = null, e.chehuiNode = null, e.yichuNode = null, e.shengshouNode = null, e.toushiNode = null, e.wenquxingNode = null, e.game = null, e.type = 1, e;
  }

  return i(e, t), e.prototype.onLoad = function () {
    var t = this;
    this.shareBtn.on(cc.Node.EventType.TOUCH_END, function (e) {
      h["default"].shareRecorder({
        success: function success() {
          u["default"].shareVideoCount++, u["default"].shareVideo = !0, t.useItem(), t.hide();
        },
        query: ""
      }), e.stopPropagation();
    }, this), this.videoBtn.on(cc.Node.EventType.TOUCH_END, function (e) {
      h["default"].showRewardVideo({
        success: function success() {
          t.useItem(), t.hide();
        }
      }), e.stopPropagation();
    }, this), this.closeBtn.on(cc.Node.EventType.TOUCH_END, function (e) {
      t.hide(), e.stopPropagation();
    }, this);
  }, e.prototype.hide = function () {
    this.game && (this.game._zanting = !1), h["default"].startRecorder(), p.UIMgr.hide(d["default"].ItemUI, !1, !0);
  }, e.prototype.useItem = function () {
    this.game ? (1 == this.type && this.game.xipai(), 2 == this.type && this.game.undo(), 3 == this.type && this.game.yichu(!0), 4 == this.type && this.game.shengshou(), 5 == this.type && this.game.toushi(), 6 == this.type && this.game.wenquxing()) : h["default"].sendEvent({
      key: "userItemNoGame",
      value: {
        type: this.type
      }
    }), h["default"].sendEvent({
      key: "userItem",
      value: {
        type: this.type
      }
    });
  }, e.prototype.init = function (t) {
    this.game = t.game, this.type = t.type;
  }, e.prototype.onShow = function () {
    this.node.active = !0, this.childNode.scale = 0, cc.tween(this.childNode).to(0.3, {
      scale: 1
    }).call(function () {}).start(), h["default"].getRecorderTime() > 2e4 && h["default"].isTT() && !h["default"].getRecorderState() && u["default"].shareVideoCount < 2 ? (this.videoBtn.active = !0, this.shareBtn.active = !0) : (this.videoBtn.active = !0, this.shareBtn.active = !1), this.xipaiNode.active = !1, this.chehuiNode.active = !1, this.yichuNode.active = !1, this.shengshouNode.active = !1, this.toushiNode.active = !1, this.wenquxingNode.active = !1, 1 == this.type && (this.xipaiNode.active = !0), 2 == this.type && (this.chehuiNode.active = !0), 3 == this.type && (this.yichuNode.active = !0), 4 == this.type && (this.shengshouNode.active = !0), 5 == this.type && (this.toushiNode.active = !0), 6 == this.type && (this.wenquxingNode.active = !0), this.game._zanting = !0;
  }, e.prototype.onEnable = function () {
    h["default"].isTT() && h["default"].showBanner();
  }, e.prototype.onDisable = function () {
    h["default"].isTT() && h["default"].hideBanner();
  }, e.prototype.start = function () {}, s([a(cc.Node)], e.prototype, "childNode", void 0), s([a(cc.Node)], e.prototype, "shareBtn", void 0), s([a(cc.Node)], e.prototype, "videoBtn", void 0), s([a(cc.Node)], e.prototype, "closeBtn", void 0), s([a(cc.Node)], e.prototype, "xipaiNode", void 0), s([a(cc.Node)], e.prototype, "chehuiNode", void 0), s([a(cc.Node)], e.prototype, "yichuNode", void 0), s([a(cc.Node)], e.prototype, "shengshouNode", void 0), s([a(cc.Node)], e.prototype, "toushiNode", void 0), s([a(cc.Node)], e.prototype, "wenquxingNode", void 0), s([c], e);
}(l["default"]);

o["default"] = f;

cc._RF.pop();